package fr.umlv.m2.jee.pmlv.web.professor;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import javax.naming.NamingException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import fr.umlv.m2.jee.pmlv.persistence.cursus.Specialty;
import fr.umlv.m2.jee.pmlv.persistence.cursus.SpecialtySubject;
import fr.umlv.m2.jee.pmlv.persistence.subject.Exam;
import fr.umlv.m2.jee.pmlv.persistence.subject.KeyWord;
import fr.umlv.m2.jee.pmlv.persistence.subject.Lesson;
import fr.umlv.m2.jee.pmlv.persistence.subject.Project;
import fr.umlv.m2.jee.pmlv.persistence.subject.TD;
import fr.umlv.m2.jee.pmlv.persistence.subject.TP;
import fr.umlv.m2.jee.pmlv.service.cursus.DisplayCursus;
import fr.umlv.m2.jee.pmlv.service.cursus.IDisplayCursusService;
import fr.umlv.m2.jee.pmlv.service.subject.DisplayAbstractTheme;
import fr.umlv.m2.jee.pmlv.service.subject.DisplaySubject;
import fr.umlv.m2.jee.pmlv.service.subject.IDisplayAbstractThemeService;
import fr.umlv.m2.jee.pmlv.service.subject.IDisplaySubjectService;
import fr.umlv.m2.jee.pmlv.service.user.User;
import fr.umlv.m2.jee.pmlv.service.user.impl.UserService;

/**
 * Servlet wich represents subject's informations of a professor.
 * @author Alexandre
 */
public class ManagementOfSubjects extends HttpServlet {
    // Variables
    private User user = null;   //Contains informations about user
    private List<Integer> years = new ArrayList<Integer>(); //Contains years when professor teaching a subject
    int currentYear = 0;
    private List<DisplayCursus> cursus = new ArrayList<DisplayCursus>();    //Subjects teached by user
    private Long idSubject = Long.valueOf("-1");
    private Long idSpesub =  Long.valueOf("-1");
    private DisplaySubject subject = null;
    private List<DisplayAbstractTheme> themes = new ArrayList<DisplayAbstractTheme>();
    private List<User> responsibles = new ArrayList<User>();
    private boolean responsible = false;


    /**
     * @see HttpServlet#HttpServlet()
     */
    public ManagementOfSubjects() {
            super();
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response).
    */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        doPost(request,response);
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response).
    */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        //Data
        user = null;
        years.clear();
        currentYear = 0;
        cursus.clear();
        idSubject = Long.valueOf("-1");
        idSpesub =  Long.valueOf("-1");
        subject = null;
        themes.clear();
        responsibles.clear();
        responsible = false;


        //Retrieve informations about user
        HttpSession session = request.getSession(true);
        user = (User)session.getAttribute("user");
        years.addAll((List<Integer>)session.getAttribute("years"));

        //Retrieve list of subjects teached by user for current year
        ServletContext context = getServletContext();
        WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
        IDisplayCursusService cursusService = (IDisplayCursusService) applicationContext.getBean("defautDisplayCursusService");
        currentYear = Integer.parseInt(request.getParameter("year"));
        cursus.addAll(cursusService.getCursusByProfessorUidAndByYear(user.getuId(), currentYear));


        //Retrieve filter selected and students
        if(request.getParameter("subject")!=null)
        {
            idSpesub = Long.parseLong(request.getParameter("spesub"));
            idSubject = Long.parseLong(request.getParameter("subject"));
            IDisplaySubjectService subService = (IDisplaySubjectService) applicationContext.getBean("defautDisplaySubjectService");
            subject = subService.getDisplaySubjectbyId(idSubject);
            IDisplayAbstractThemeService themeService = (IDisplayAbstractThemeService) applicationContext.getBean("defautDisplayAbstractThemeService");
            themes.addAll( themeService.getAbstractThemeBySubjectIdAndByYear(idSubject, currentYear) );
            UserService userService = (UserService) applicationContext.getBean("ldapUser");
            try {
                responsibles.addAll(userService.getResponsibleBySubjectAndByYear(idSubject, currentYear));
                for(User u:responsibles)
                {
                    if(u.getuId().equals(user.getuId()))
                        responsible = true;
                }
            } catch (NamingException ex) { }
        }
        session.setAttribute("back", getServletContext().getContextPath()+"/Professor/ManagementOfSubjects?year="+currentYear+"&subject="+idSubject+"&spesub="+idSpesub);


        //View
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">");
        out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\" >");

        out.println(" <head>");
        out.println("   <title>PMLV : Portail Universitaire de Marne-La-Vall&eacute;e</title>");
        out.println("   <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");
        out.println("   <link rel=\"stylesheet\" media=\"screen\" type=\"text/css\" href=\"../css/professor/professor.css\" />");
        out.println("   <link rel=\"stylesheet\" media=\"screen\" type=\"text/css\" href=\"../css/professor/managementOfSubjects.css\" />");
        out.println(" </head>");

        out.println(" <body>");

        out.println("   <div id=\"header\">");
        out.println("     <ul>");
        out.println("       <li class=\"menuItem menuItemSpacing\"><a href=\"../Professor\">Accueil</a></li>");
        out.println("       <li class=\"menuItem menuItemSpacing\"><a href=\"ListOfStudents\">Listes des &eacute;tudiants</a></li>");
        out.println("       <li class=\"menuItem menuItemSpacing cursor\">Emploi du temps");
        out.println("         <ul class=\"subMenuBar\">");
        out.println("           <li class=\"subMenu\"><a href=\"ScheduleOfCoursesAndExams\">Cours et examens</a></li>");
        out.println("           <li class=\"subMenu\"><a href=\"ScheduleOfWorksToMake\">Rendu de travaux</a></li>");
        out.println("         </ul>");
        out.println("       </li>");
        out.println("       <li class=\"menuItem menuItemSpacing cursor\">Gestion de mati&egrave;re");
        out.println("         <ul class=\"subMenuBar\">");
        for(Integer year:years)
        {
            out.println("           <li class=\"subMenu\"><a href=\"ManagementOfSubjects?year="+year+"\">"+ year +"-"+ (year+1) +"</a></li>");
        }
        out.println("         </ul>");
        out.println("       </li>");
        out.println("       <li id=\"menuItemMargin\" class=\"menuItem\"><a href=\"../j_spring_security_logout\">Se d&eacute;connecter</a></li>");
        out.println("     </ul>");
        out.println("   </div>");

        getDivContent(out, request, response);

        out.println("   <div id=\"footer\">");
        out.println("     <div id=\"copyright\">&copy; Universit&eacute; Paris-Est Marne-la-Vall&eacute;e</div>");
        out.println("     <div>PMLV v1.0 </div>");
        out.println("   </div>");

        out.println(" </body>");

        out.println("</html>");
        out.close();
    }

    /**
     *  Content of page
     */
    private void getDivContent(PrintWriter out, HttpServletRequest request, HttpServletResponse response)
    {
        List< List<Integer> > types = new ArrayList< List<Integer> >(5);
        for(int i=0;i<5;i++) {
            types.add( new ArrayList<Integer>() );
        }
        for(int i=0;i<themes.size();i++)
        {
            if(themes.get(i).getAbstractTheme() instanceof Lesson) types.get(0).add(new Integer(i));
            else if(themes.get(i).getAbstractTheme() instanceof TD) types.get(1).add(new Integer(i));
            else if(themes.get(i).getAbstractTheme() instanceof TP) types.get(2).add(new Integer(i));
            else if(themes.get(i).getAbstractTheme() instanceof Project) types.get(3).add(new Integer(i));
            else if(themes.get(i).getAbstractTheme() instanceof Exam) types.get(4).add(new Integer(i));
        }
        int tmp = 0;
        if(Calendar.getInstance(Locale.FRENCH).get(Calendar.MONTH)>9) tmp = Calendar.getInstance(Locale.FRENCH).get(Calendar.YEAR);
        else tmp = Calendar.getInstance(Locale.FRENCH).get(Calendar.YEAR) - 1;


        out.println("   <div id=\"content\">");
        if(idSubject==-1)
            out.println("     <div id=\"title\">Informations sur une mati&egrave;re</div>");
        else
            out.println("     <div id=\"title\">Informations sur la mati&egrave;re "+subject.getName()+"</div>");

        out.println("       <table id=\"menu\">");
        for(DisplayCursus c:cursus)
        {
            out.println("         <tr><td colspan=\"2\"><li>"+ c.getName() +"</li></td></tr>");
            for(Specialty spe:c.getSpecialties())
            {
                out.println("         <tr>");
                out.println("           <td class=\"speciality\"><li> "+ spe.getName() +"</li></td>");
                out.println("           <td class=\"arrow\"></td>");
                out.println("         </tr>");
                for(SpecialtySubject sub:spe.getSpecialtySubject())
                {
                    out.println("         <tr>");
                    out.println("           <td class=\"subject\"><li> "+ sub.getSubject().getName() +"</li></td>");
                    out.println("           <td class=\"arrow\"><a href=\"ManagementOfSubjects?year="+currentYear+"&subject="+sub.getSubject().getId()+"&spesub="+sub.getId()+"\"><img src=\"../images/next.jpg\"/></a></td>");
                    out.println("         </tr>");
                }
            }
        }
        out.println("       </table>");


        if(idSubject!=-1)
        {
            out.println("         <table id=\"ManagementOfSubjectTable\">");

            //Details
            out.println("           <tr class=\"details\">");
            out.println("                <td><u>Responsable :</u>");
            for(int i=0;i<responsibles.size();i++)
            {
                out.println("                "+responsibles.get(i).getFirstname()+" "+responsibles.get(i).getLastname());
                if(i<responsibles.size()-1) out.println("                ,");
            }
            out.println("                <br/>");
            out.println("                <u>Mots cl&eacute;s :</u>");
            int key=0;
            for(KeyWord keyWord:subject.getKeyWords())
            {
                out.println("                "+keyWord.getWord());
                if(key<subject.getKeyWords().size()-1) out.println("                ,");
                key++;
            }
            out.println("                <br/>");
            for(SpecialtySubject spesub:subject.getSpecialtySubject())
            {
                if(spesub.getId()==idSpesub)
                {
                    out.println("                <u>Ects :</u> "+spesub.getEcts()+" <br/>");
                    out.println("                <u>Semestre :</u> "+spesub.getSemester()+" <br/>");
                }
            }
            if(responsible && tmp==currentYear) out.println("           <a href=\"MarkTheme?subject="+idSubject+"\">Modifier les notes des &eacute;tudiants suivant cette mati&egrave;re</a> <br/>");
            out.println("           <tr> <td> <li>");


            //Lessons
            out.println("               <label for=\"lessons\"><a href=\"#\">Cours</a></label>");
            out.println("               <input id=\"lessons\" type=\"checkbox\"/>");
            getContentForLessons(out, responsible, types.get(0),tmp);


            //Tds
            out.println("               <label for=\"tds\"><a href=\"#\">Travaux Dirig&eacute;s</a></label>");
            out.println("               <input id=\"tds\" type=\"checkbox\"/>");
            getContentForWorks(out, responsible, types.get(1), 0,tmp);


            //Tps
            out.println("               <label for=\"tps\"><a href=\"#\">Travaux Pratiques</a></label>");
            out.println("               <input id=\"tps\" type=\"checkbox\"/>");
            getContentForWorks(out, responsible, types.get(2), 1,tmp);


            //Projets
            out.println("               <label for=\"projects\"><a href=\"#\">Projets</a></label>");
            out.println("               <input id=\"projects\" type=\"checkbox\"/>");
            getContentForProjects(out, responsible, types.get(3),tmp);

            //Exams
            out.println("               <label for=\"exams\"><a href=\"#\">Examens</a></label>");
            out.println("               <input id=\"exams\" type=\"checkbox\"/>");
            getContentForExams(out, responsible, types.get(4), tmp);

            out.println("           </li> </td> </tr>");

            out.println("         </table>");
        }

        out.println("   </div>");
    }

    private void getContentForLessons(PrintWriter out, boolean responsible, List<Integer> lessons, int tmp)
    {
        out.println("               <ol>");
        out.println("                   <table class=\"sub-infos\">");
        for(int i=0;i<lessons.size();i++)
        {
            DisplayAbstractTheme theme=themes.get(lessons.get(i));
            //Color
            if(i%2 == 0) out.println("           <tr class=\"tableLightBackground\">");
            else out.println("           <tr class=\"tableDarkBackground\">");
            //Name
            out.println("                       <td class=\"name\">"+ theme.getName() +"</td>");
            //Link
            out.println("                       <td class=\"link\"> &nbsp </td> ");
            if(theme.getPdfFileName()==null) out.println("                       <td class=\"link\"> &nbsp </td>");
            else out.println("                       <td class=\"link\"><a href=\""+theme.getPdfFileName()+"\">pdf</a></td>");
            //State
            out.println("                       <td class=\"state\"> &nbsp </td>");
            //Options
            if(responsible && tmp==currentYear)
            {
                if(theme.getPublished()==0) out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=0\"><img src=\"../images/add.png\"/></td>");
                else out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"><a href=\"EditTheme?action=edit&typeTheme=lesson&theme="+theme.getId()+"\"><img src=\"../images/edit.png\"/></td> ");
                out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=1\"><img src=\"../images/delete.png\"/></a></td>");
            }
            else
            {
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
            }
            out.println("                   </tr> ");
        }
        //Empty lessons
        if(lessons.isEmpty())
            out.println("                   <tr class=\"tableLightBackground\"><td>Aucun Cours de disponible</td></tr>");
        out.println("                   </table>");
        //Add Lesson
        if(responsible && tmp==currentYear) out.println("                   <center><a href=\"EditTheme?action=add&typeTheme=lesson\">Ajouter un Cours</a></center>");
        out.println("               </ol>");
    }

    private void getContentForWorks(PrintWriter out, boolean responsible, List<Integer> works, int type, int tmp)
    {
        out.println("               <ol>");
        out.println("                   <table class=\"sub-infos\">");
        for(int i=0;i<works.size();i++)
        {
            DisplayAbstractTheme theme=themes.get(works.get(i));
            //Color
            if(i%2 == 0) out.println("           <tr class=\"tableLightBackground\">");
            else out.println("           <tr class=\"tableDarkBackground\">");
            //Name
            out.println("                       <td class=\"name\">"+theme.getName()+"</td>");
            //Link
            if(theme.getHtmlFileName()==null) out.println("                       <td class=\"link\"> &nbsp </td>");
            else out.println("                       <td class=\"link\"><a href=\""+theme.getHtmlFileName()+"\">html</a></td>");
            if(theme.getPdfFileName()==null) out.println("                       <td class=\"link\"> &nbsp </td>");
            else out.println("                       <td class=\"link\"><a href=\""+theme.getPdfFileName()+"\">pdf</a></td>");
            //State
            if(theme.getRecordDate()==null || tmp!=currentYear) out.println("                       <td class=\"state\"> &nbsp </td>");
            else if(theme.getRecordDate().getDeadLine().before(new Date())) out.println("                       <td class=\"state\"><a href=\"MarkTheme?theme="+theme.getId()+"\">Noter</a></td>");
            else
            {
                String date = "";
                if(theme.getRecordDate().getDeadLine().getDate()/10==0) date="0"+theme.getRecordDate().getDeadLine().getDate()+"/";
                else date=theme.getRecordDate().getDeadLine().getDate()+"/";
                if((theme.getRecordDate().getDeadLine().getMonth()+1)/10==0) date=date+"0"+(theme.getRecordDate().getDeadLine().getMonth()+1);
                else date=date+(theme.getRecordDate().getDeadLine().getMonth()+1);
                out.println("                       <td class=\"state\">A rendre ("+ date +")</td>");
            }
            //Options
            if(tmp==currentYear)
            {
                if(theme.getPublished()==0) out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=0\"><img src=\"../images/add.png\"/></td>");
                else out.println("                       <td class=\"option\"> &nbsp </td>");
                if(type==0)
                    out.println("                       <td class=\"option\"><a href=\"EditTheme?action=edit&typeTheme=td&theme="+theme.getId()+"\"><img src=\"../images/edit.png\"/></td> ");
                else
                    out.println("                       <td class=\"option\"><a href=\"EditTheme?action=edit&typeTheme=tp&theme="+theme.getId()+"\"><img src=\"../images/edit.png\"/></td> ");
                out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=1\"><img src=\"../images/delete.png\"/></a></td>");
            }
            else
            {
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
            }
        }
        //Empty works
        if(works.isEmpty() && type==0) out.println("                   <tr class=\"tableLightBackground\"><td>Aucun Travaux Dirig&eacute;s de disponible</td></tr>");
        else if(works.isEmpty()) out.println("                   <tr class=\"tableLightBackground\"><td>Aucun Travaux Pratiques de disponible</td></tr>");
        out.println("                   </table>");
        //Add work
        if(type==0 && tmp==currentYear) out.println("                   <center><a href=\"EditTheme?action=add&typeTheme=td\">Ajouter un Travaux Dirig&eacute;s</a></center>");
        else if(tmp==currentYear) out.println("                   <center><a href=\"EditTheme?action=add&typeTheme=tp\">Ajouter un Travaux Pratiques</a></center>");
        out.println("               </ol>");
    }

    private void getContentForProjects(PrintWriter out, boolean responsible, List<Integer> projects, int tmp)
    {
        out.println("               <ol>");
        out.println("                   <table class=\"sub-infos\">");
        for(int i=0;i<projects.size();i++)
        {
            DisplayAbstractTheme theme=themes.get(projects.get(i));
            //Color
            if(i%2 == 0) out.println("           <tr class=\"tableLightBackground\">");
            else out.println("           <tr class=\"tableDarkBackground\">");
            //Name
            out.println("                       <td class=\"name\">"+theme.getName()+"</td>");
            //Link
            if(theme.getHtmlFileName()==null) out.println("                       <td class=\"link\"> &nbsp </td>");
            else out.println("                       <td class=\"link\"><a href=\""+theme.getHtmlFileName()+"\">html</a></td>");
            if(theme.getPdfFileName()==null) out.println("                       <td class=\"link\"> &nbsp </td>");
            else out.println("                       <td class=\"link\"><a href=\""+theme.getPdfFileName()+"\">pdf</a></td>");
            //State
            if(theme.getRecordDate()==null || tmp!=currentYear) out.println("                       <td class=\"state\"> &nbsp </td>");
            else if(theme.getRecordDate().getDeadLine().before(new Date()) && responsible) out.println("                       <td class=\"state\"><a href=\"MarkTheme?theme="+theme.getId()+"\">Noter</a></td>");
            else if(theme.getRecordDate().getDeadLine().before(new Date())) out.println("                       <td class=\"state\"> &nbsp </td>");
            else if(theme.getRecordDate().getDeadLine().after(new Date()))
            {
                String date = "";
                if(theme.getRecordDate().getDeadLine().getDate()/10==0) date="0"+theme.getRecordDate().getDeadLine().getDate()+"/";
                else date=theme.getRecordDate().getDeadLine().getDate()+"/";
                if((theme.getRecordDate().getDeadLine().getMonth()+1)/10==0) date=date+"0"+(theme.getRecordDate().getDeadLine().getMonth()+1);
                else date=date+(theme.getRecordDate().getDeadLine().getMonth()+1);
                out.println("                       <td class=\"state\">A rendre ("+ date +")</td>");
            }

            //Options
            if(responsible && tmp==currentYear)
            {
                if(theme.getPublished()==0) out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=0\"><img src=\"../images/add.png\"/></td>");
                else out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"><a href=\"EditTheme?action=edit&typeTheme=project&theme="+theme.getId()+"\"><img src=\"../images/edit.png\"/></td> ");
                out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=1\"><img src=\"../images/delete.png\"/></a></td>");
            }
            else
            {
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
            }
            out.println("                   </tr> ");
        }
        //Empty projects
        if(projects.isEmpty())
            out.println("                   <tr class=\"tableLightBackground\"><td>Aucun Projet de disponible</td></tr>");
        out.println("                   </table>");
        //Add Project
        if(responsible && tmp==currentYear) out.println("                   <center><a href=\"EditTheme?action=add&typeTheme=project\">Ajouter un Projet</a></center>");
        out.println("               </ol>");
    }

    private void getContentForExams(PrintWriter out, boolean responsible, List<Integer> exams, int tmp)
    {
        out.println("               <ol>");
        out.println("                   <table class=\"sub-infos\">");
        for(int i=0;i<exams.size();i++)
        {
            DisplayAbstractTheme theme=themes.get(exams.get(i));
            //Color
            if(i%2 == 0) out.println("           <tr class=\"tableLightBackground\">");
            else out.println("           <tr class=\"tableDarkBackground\">");
            //Name
            out.println("                       <td class=\"name\">"+theme.getName()+"</td>");
            //Link
            out.println("                       <td class=\"link\"> &nbsp </td>");
            if(theme.getPdfFileName()==null) out.println("                       <td class=\"link\"> &nbsp </td>");
            else out.println("                       <td class=\"link\"><a href=\""+theme.getPdfFileName()+"\">pdf</a></td>");
            //State
            out.println("                       <td class=\"state\"> &nbsp </td>");
            //Options
            if(responsible && tmp==currentYear)
            {
                if(theme.getPublished()==0) out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=0\"><img src=\"../images/add.png\"/></td>");
                else out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"><a href=\"EditTheme?action=edit&typeTheme=exam&theme="+theme.getId()+"\"><img src=\"../images/edit.png\"/></td> ");
                out.println("                       <td class=\"option\"><a href=\"Confirm?theme="+theme.getId()+"&confirm=1\"><img src=\"../images/delete.png\"/></a></td>");
            }
            else
            {
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
                out.println("                       <td class=\"option\"> &nbsp </td>");
            }
            out.println("                   </tr> ");
        }
        //Empty exam
        if(exams.isEmpty())
            out.println("                   <tr class=\"tableLightBackground\"><td>Aucun Examen de disponible</td></tr>");
        out.println("                   </table>");
        //Add exam
        if(responsible && tmp==currentYear) out.println("                   <center><a href=\"EditTheme?action=add&typeTheme=exam\">Ajouter un Examen</a></center>");
        out.println("               </ol>");
    }
}
